PROCESS SYNCHRONIZATION
Experiment Number 1 : Counting Semaphores
Algorithm
• Step 1: Let entity access a critical condition.
• Step 2: Entity executes wait (P) in binary semaphore.
• Step 3: Semaphore checks integer value
If integer value=0, Semaphore places entity in Semaphore’s queue.
Entity waits and then Semaphore provides access unit to entity.
If integer value!=0, Semaphore decrements integer value by one.
Then Semaphore provides access unit to entity.
• Step 4: Entity access critical section & executes on it.
• Step 5: Entity executes signal(V) in binary semaphore.
• Step 6: Entity leaves critical section.
Entity waits and then Semaphore provides access unit to entity.
If integer value!=0, Semaphore decrements integer value by one.
Then Semaphore provides access unit to entity.